import reshandler from 'services/response-handler'
/*
 * 填写订单
 * （获取收货地址、支付方式、物流方式、优惠券，默认商品等等）
 */
function makeData(response) {
  return Object.assign({}, response, {
    balance: response.balance || "0.00",
    bean: response.bean || "0",
    beanRate: response.beanRate || "0",
    couponCodes: response.couponCodes || [],
    couponGroups: response.couponGroups || [],
    hasCoupons: response.hasCoupons || "0",
    hasSetPayPassword: response.hasSetPayPassword || "0",
    maxOffsetBean: response.maxOffsetBean || "0",
    maxRate: response.maxRate || "0",
    paymentMethods: response.paymentMethods || [],
    receivers: response.receivers || [],
    shippingMethods: response.shippingMethods || [],
    unReceivedCoupons: response.unReceivedCoupons || []
  })
}
export default function (params, success, fail) {
  // request 
  params = Object.assign({}, params, {
    methodName: "FillInOrder",
  })

  // invoke
  this.$.get(params)
    .then(reshandler.success(success, fail, makeData), reshandler.error(fail))
}
